#pragma once

#include <fstream>
#include <vector>

#include "data_storage.hpp"

class IMUFileLoader {
private:
    std::ifstream m_imu_data_file;

public:
    IMUFileLoader(std::string filename, double timestamp = -1);
    ~IMUFileLoader() {}

    std::vector<iNav::IMUData> m_imu_vec;
};

IMUFileLoader::IMUFileLoader(std::string filename, double timestamp)
    : m_imu_data_file(filename.c_str(), std::ios::in | std::ios::binary) {
    iNav::IMUData imu_frame;
    while (m_imu_data_file.read((char *)&imu_frame, sizeof(imu_frame))) {
        if (imu_frame.timestamp >= timestamp)
            m_imu_vec.push_back(imu_frame);
    }
}
